package com.bdqn.design;

import com.bdqn.design.factory.SimpleDaoFactory;
import com.bdqn.design.pojo.News;
import com.bdqn.design.service.NewsService;
import com.bdqn.design.service.impl.NewsServiceImpl;

/**
 * Test01SimpleDaoFactory
 *
 * @author LILIBO
 * @since 2024/7/4
 */
public class Test01SimpleDaoFactory {

    public static void main(String[] args) {
        // NewsService newsService = new NewsServiceImpl();
        // 通过依赖倒置，完成对象注入
        // newsService.setNewsDao(SimpleDaoFactory.getMySQLInstance());
        // newsService.setNewsDao(SimpleDaoFactory.getOracleInstance());
        String daoImplKey = "redis";
        NewsService newsService = new NewsServiceImpl(SimpleDaoFactory.getInstance(daoImplKey));
        newsService.save(new News());
    }

}
